package com.woniuxy.enums.article;

import lombok.Getter;

/**
 * 点赞对象状态枚举
 *
 * @author 饶志
 * @version 1.0
 * @since 2025-07-16  01:23
 */
@Getter
public enum ArticleLikeStatus {

    LIKE(1, "点赞"),
    DISLIKE(0, "取消点赞"),
    ;

    private final Integer status;

    private final String description;

    ArticleLikeStatus(Integer status, String description) {
        this.status = status;
        this.description = description;
    }

    /**
     * 根据状态码获取对应的枚举
     *
     * @param status 状态码
     * @return 对应的枚举对象
     */
    public static ArticleLikeStatus fromStatus(Integer status) {
        for (ArticleLikeStatus s : values()) {
            if (s.getStatus().equals(status)) {
                return s;
            }
        }
        throw new IllegalArgumentException("Invalid status: " + status);
    }
}
